<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset="utf-8" />
<title>脚本执行页</title>
<base target="_blank" />
<script src="../../js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="../../js/vue.js" type="text/javascript"></script>
<style>
* {
	padding: 0px;
	margin: 0px;
}

a {
	color: White
}

body {
	font-family: Arial, Helvetica, sans-serif;
	background:
		url(http://keleyi.com/keleyi/phtml/divcss/21/images/grass.jpg)
		no-repeat center;
	font-size: 13px;
}

img {
	border: 0;
}

.lg {
	width:600px;
    height: 800px;
    margin: 100px auto;
    border: 1px solid;
}

.lg_top {
	height: 200px;
	width: 468px;
}

.lg_main {
	width: 400px;
	height: 180px;
	margin: 0 25px;
}

</style>
</head>

<body class="b">
	<div class="lg">
		<form action="#" method="POST">
			<div class="lg_top"></div>
			<div class="lg_main">
				<div>
					<label>command：<input name="command" id="command" style="width: 400px;height: 50px;" /> </label>
				</div>
				<br>
				<input type="button" value="开始执行" id="bn" />
			</div>
		</form>
	</div>
	<div id="result">
		<textarea v-model="result"  ></textarea>
	</div>
</body>
<script type="text/javascript">
    var vm = new Vue({
        el: '#result',
        data: {
           result:""
        }
    });

	$("#bn").click(
			function() {
				var command = $("#command").val();
				var error = "";
				if (command.length == "") {
					error += "command不能为空";
					error += "\n";
				}

				if (error != "") {
					alert(error);
				} else {
					$.ajax({
						type : 'POST',
						dataType : 'json',
						url : '/command',
						contentType : 'application/json;charset=UTF-8',
						data : JSON.stringify({
							"command" : command
						}),
						success : function(data) {//返回json结果
							if(data){
								console.log(data)
								vm.result = data;
							}
						}
					});
				}
			});
</script>
</html>
